package com.example.novelstory.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration//配置注解
//把逻辑路径自动映射到物理路径
public class UploadFilePathConfig implements WebMvcConfigurer {
//   Value读取文件注入
    @Value( "${file.staticAccessPath}")
    private String staticAccessPath;
    @Value( "${file.uploadFolder}")
    private String uploadFolder;
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler(staticAccessPath).addResourceLocations("file:" + uploadFolder);
    }
}
